package com.zkingsoft.actions.customer;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.zkingsoft.actions.common.BaseController;
import com.zkingsoft.model.Matchs;
import com.zkingsoft.model.Sort;
import com.zkingsoft.model.Team;
import com.zkingsoft.services.MatchsService;
import com.zkingsoft.services.SortService;
import com.zkingsoft.services.TeamService;

/**
 * @project MatrixCms
 * @package com.zkingsoft.actions.superaction
 * @class ShowController.java
 * @author Matrix-J E-mail:<935090232@qq.com>
 * @date 2016年4月21日10:31
 * @description 普通用户
 */
@Controller
@RequestMapping(value = "show")
public class ShowController extends BaseController {

	@Resource
	private MatchsService matchsService;
	@Resource
	private SortService sortService;
	@Resource
	private TeamService teamService;
	
	
	@RequestMapping(value = "showList")
	public String  showList(HttpServletRequest request, Matchs matchs){
		//小组赛
		matchs.setRank(10);
		List<Matchs> list10 = matchsService.findByModel(matchs);
		if(list10!=null&&list10.size()>0){
			request.setAttribute("list10", list10);
		}
		//8强
		matchs.setRank(8);
		List<Matchs> list8 = matchsService.findByModel(matchs);
		if(list8!=null&&list8.size()>0){
			request.setAttribute("list8", list8);
		}
		//4强
		matchs.setRank(4);
		List<Matchs> list4 = matchsService.findByModel(matchs);
		if(list4!=null&&list4.size()>0){
			request.setAttribute("list4", list4);
		}
		//半决赛
		matchs.setRank(2);
		List<Matchs> list2 = matchsService.findByModel(matchs);
		if(list2!=null&&list2.size()>0){
			request.setAttribute("list2", list2);
		}
		//决赛
		matchs.setRank(1);
		List<Matchs> list1 = matchsService.findByModel(matchs);
		if(list1!=null&&list1.size()>0){
			request.setAttribute("list1", list1);
		}
		return "common/sc";
	}
	//获取分组信息
	@RequestMapping(value = "sortInfo")
	public String getSortInfo(Sort sort,HttpServletRequest request){
		List<Sort> sorts = sortService.findByModel(sort);
		if(sorts!=null&&sorts.size()>0){
			request.setAttribute("sorts", sorts);
		}
		return "common/qd";
	}
	//获取评论
	@RequestMapping(value = "selectRecommend")
	public String getRecommend(Long id, HttpServletRequest request){
		Team team = teamService.findById(id);
		request.setAttribute("team", team);
		return "common/oneqd";
	}
	
}
